package cn.stylefeng.guns.sys.modular.system.controller;


import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.GcgWsjd;
import cn.stylefeng.guns.sys.modular.system.mapper.MouldMapper;
import cn.stylefeng.guns.sys.modular.system.model.params.GcgWsjdParam;
import cn.stylefeng.guns.sys.modular.system.model.result.GcgWsjdResult;
import cn.stylefeng.guns.sys.modular.system.service.WsjdService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 网上建店信息gcg_wsjd控制器
 *
 * @author 
 * @Date 2021-06-15 11:02:42
 */
@Controller
@RequestMapping("/wsjd")
public class WsjdController extends BaseController {

    private String PREFIX = "/modular/system/wsjd";

    @Autowired
    private WsjdService wsjdService;

    /**
     * 跳转到主页面
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/wsjd.html";
    }

    /**
     * 新增页面
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/wsjd_add.html";
    }

    /**
     * 编辑页面
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("/edit")
    public String edit(Long gcgWsjdId, ModelMap map) {
        GcgWsjdResult detail = this.wsjdService.getById(gcgWsjdId);
        map.put("phone",detail.getYyjl());
        return PREFIX + "/wsjd_edit.html";
    }

    /**
     * 新增接口
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(GcgWsjdParam gcgWsjdParam) {
        this.wsjdService.add(gcgWsjdParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(GcgWsjdParam gcgWsjdParam) {
        this.wsjdService.update(gcgWsjdParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("/delete")
    @ResponseBody
    public int delete(GcgWsjdParam gcgWsjdParam) {
        return this.wsjdService.delete(gcgWsjdParam);
    }

    /**
     * 查看详情接口
     *
     * @author 
     * @Date 2021-06-15
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(GcgWsjdParam gcgWsjdParam) {
//        GcgWsjd detail = this.wsjdService.getById(gcgWsjdParam.getGcgWsjdId());
        GcgWsjdResult detail = this.wsjdService.getById(gcgWsjdParam.getGcgWsjdId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author 
     * @Date 2021-06-15
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(GcgWsjdParam gcgWsjdParam) {
        return this.wsjdService.findPageBySpec(gcgWsjdParam);
    }

}


